package br.com.foxinline.servico;

import br.com.foxinline.modelo.Imovel;
import br.com.foxinline.modelo.Objeto;
import javax.ejb.Stateless;
import javax.persistence.Query;


/**
 *
 * @author cadomeireles
 */
@Stateless
public class ObjetoServico extends ServicoGenerico<Objeto> {
    
    public ObjetoServico() {
        super(Objeto.class);
    }
    
    public Objeto pesquisar(Imovel imovel) {
        String sql = "select imovel.objeto from Imovel imovel where imovel = :imovel";
        
        Query query = getEntityManager().createQuery(sql);
        
        if (imovel != null && imovel.getId() != null) {
            query.setParameter("imovel", imovel);
        }

        return (Objeto) query.getSingleResult();
    }

}
